package com.drug.mingkang.controller;

import com.drug.mingkang.model.ImmPurchaseDeatis;
import com.drug.mingkang.model.vo.ImmPurchaseDeatisVo;
import com.drug.mingkang.service.ImmPurchaseDeatisService;
import com.drug.mingkang.utils.Tools;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 分公司采购明细(ImmPurchaseDeatis)表控制层
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:14
 */
@RestController
@RequestMapping("immPurchaseDeatis")
public class ImmPurchaseDeatisController {
    /**
     * 服务对象
     */
    @Resource
    private ImmPurchaseDeatisService immPurchaseDeatisService;

    @Resource
    private Tools tools;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ImmPurchaseDeatis selectOne(String id) {
        return this.immPurchaseDeatisService.queryById(id);
    }


    /**
     * 通过实体作为筛选条件查询
     * @param immPurchaseDeatisVo
     * @return
     */
    @PostMapping("queryAll")
    public Map<String,Object> queryAll(ImmPurchaseDeatisVo immPurchaseDeatisVo){

        List<ImmPurchaseDeatis> list = immPurchaseDeatisService.queryAll(immPurchaseDeatisVo);
        int count = immPurchaseDeatisService.count(immPurchaseDeatisVo);
        Map<String,Object> map = tools.limit(list,count);
        return map;
    }

}